home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 031a / winsql20.zip / EXAMPLEC.C < prev    next >
C/C++ Source or Header  |  1991-10-26  |  18KB  |  531 lines

  1. /*
  2.  * EXAMPLEC.C - Orion SQL API example in 'C'
  3.  *
  4.  * LANGUAGE      : Microsoft C6.0
  5.  * MODEL         : Small
  6.  * ENVIRONMENT   : Microsoft Windows 3.0
  7.  *
  8.  * Developed by:
  9.  *   Philip Roll
  10.  *   Ming-Li Wang
  11.  *
  12.  * (C) Copyright 1991
  13.  * Stellar Industries
  14.  * 3335 S. Falcon Ridge Road
  15.  * Diamond Bar  CA 91765
  16.  *
  17.  */
  18.  
  19. #define OEMRESOURCE
  20. #define NOCOMM
  21. #include    <windows.h>
  22. #include    <memory.h>
  23. #include    "sql.h"
  24. #include    "examplec.h"
  25.  
  26. /*
  27.  *
  28.  * Define macros:
  29.  *
  30.  */
  31.  
  32. #define IDC_RECORD_BOX                  100
  33. #define IDC_RECORD_STATIC               101
  34. #define IDC_TABLE_BOX                   200
  35. #define IDC_TABLE_STATIC                201
  36. #define IDC_USER_BOX                    300
  37. #define IDC_USER_STATIC                 301
  38.  
  39. #define mExampleMargin                  4
  40.  
  41. /*
  42.  *
  43.  * Define local variables:
  44.  *
  45.  */
  46.  
  47. static HANDLE   hSqlUser;
  48. static HCURSOR  hcursorHourGlass;
  49. static SQLCONTROL SqlControl;
  50.  
  51. static char     szExampleClass[] = "SqlExampleInC";
  52. static char     szExampleCommit[] = "commit work;";
  53. static char     szExampleTitle[] = "Sql Example In C";
  54. static HANDLE   hExampleInstance;
  55. static HWND     hwndExample;
  56. static RECT     rectExample;
  57. static TEXTMETRIC tmExampleTextMetrics;
  58. static unsigned nExampleComboBoxHeight;
  59.  
  60. static char     szRecordTitle[] = " Record: ";
  61. static char     szRecordSelectStatement[] = "select * from %s.%s;";
  62. static HWND     hwndRecordComboBox;
  63. static PSTR     pstrRecordRecord;
  64. static RECT     rectRecordComboBox;
  65. static unsigned nRecordRecordSize;
  66.  
  67. static char     szTableTitle[] = " Table: ";
  68. static char     szTableSelectStatement[] = "select TABLE_NAME from TABLES where USER_NAME = '%s' and TABLE_NAME not like '~%%';";
  69. static HWND     hwndTableComboBox;
  70. static PSTR     pstrRecordTable;
  71. static RECT     rectTableComboBox;
  72. static unsigned nTableRecordSize;
  73.  
  74. static char     szUserTitle[] = " User: ";
  75. static char     szUserSelectStatement[] = "select USER_NAME from USERS;";
  76. static HWND     hwndUserComboBox;
  77. static PSTR     pstrRecordUser;
  78. static RECT     rectUserComboBox;
  79. static unsigned nUserRecordSize;
  80.  
  81. /*
  82.  *
  83.  * Local function prototypes:
  84.  *
  85.  */
  86.  
  87. static void near ExampleCreate(void);
  88. static BOOL near ExampleInitializeApplication(void);
  89. static BOOL near ExampleInitializeInstance(int);
  90. static void near ExampleRefresh(void);
  91.  
  92. static void near RecordComboBoxCreate(HDC);
  93. static BOOL near RecordComboBoxRefresh(void);
  94.  
  95. static void near TableComboBoxCreate(HDC);
  96. static BOOL near TableComboBoxRefresh(void);
  97.  
  98. static void near UserComboBoxCreate(HDC);
  99. static BOOL near UserComboBoxRefresh(void);
  100.  
  101. /*
  102.  *
  103.  * Global function prototypes:
  104.  *
  105.  */
  106.  
  107. long FAR PASCAL ExampleWndProc(HWND, WORD, WORD, LONG);
  108. int PASCAL      WinExample(HANDLE, HANDLE, LPSTR, int);
  109.  
  110. /*
  111.  *
  112.  * Orion Example Window Creation
  113.  *
  114.  */
  115.  
  116. static void     near
  117. ExampleCreate()
  118. {
  119.   HDC             hdcDeviceContext;
  120.  
  121.   hdcDeviceContext = GetDC(hwndExample);
  122.   GetTextMetrics(hdcDeviceContext, &tmExampleTextMetrics);
  123.   nExampleComboBoxHeight = 8 * GetSystemMetrics(SM_CYMENU);
  124.   rectExample.left = 0;
  125.   rectExample.top = GetSystemMetrics(SM_CYSCREEN) / 2;
  126.   rectExample.right = rectExample.left + GetSystemMetrics(SM_CXSCREEN);
  127.   UserComboBoxCreate(hdcDeviceContext);
  128.   TableComboBoxCreate(hdcDeviceContext);
  129.   RecordComboBoxCreate(hdcDeviceContext);
  130.   ReleaseDC(hwndExample, hdcDeviceContext);
  131.   rectExample.bottom = rectExample.top + rectRecordComboBox.bottom + mExampleMargin + 2;
  132.   MoveWindow(hwndExample, rectExample.left, rectExample.top, rectExample.right - rectExample.left, rectExample.bottom - rectExample.top, FALSE);
  133.   hSqlUser = SqlLogin(&SqlControl, "SYSTEM", "ORION");
  134.   if (hSqlUser)
  135.     ExampleRefresh();
  136.   else
  137.     MessageBox(hwndExample, SqlControl.szErrorMessage, szExampleTitle, MB_OK | MB_ICONSTOP);
  138. }
  139.  
  140. /*
  141.  *
  142.  * Orion Example Application Initialization
  143.  *
  144.  */
  145.  
  146. static BOOL     near
  147. ExampleInitializeApplication()
  148. {
  149.   WNDCLASS        WndClass;
  150.  
  151.   memset(&WndClass, 0, sizeof(WndClass));
  152.   WndClass.lpfnWndProc = ExampleWndProc;
  153.   WndClass.hInstance = hExampleInstance;
  154.   WndClass.hIcon = LoadIcon(hExampleInstance, "ExampleIcon");
  155.   WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
  156.   WndClass.hbrBackground = GetStockObject(WHITE_BRUSH);
  157.   WndClass.lpszMenuName = "ExampleMenu";
  158.   WndClass.lpszClassName = szExampleClass;
  159.   if (RegisterClass(&WndClass))
  160.     return (TRUE);
  161.   else
  162.     return (FALSE);
  163. }
  164.  
  165. /*
  166.  *
  167.  * Orion Example Initialization for each instance
  168.  *
  169.  */
  170.  
  171. static BOOL     near
  172. ExampleInitializeInstance(int nCmdShow)
  173. {
  174.   HWND            hwndTemp;
  175.  
  176.   hcursorHourGlass = LoadCursor(NULL, IDC_WAIT);
  177.   hwndTemp = CreateWindow(szExampleClass,
  178.                           szExampleTitle,
  179.                           (WS_MINIMIZEBOX | WS_OVERLAPPED | WS_SYSMENU),
  180.                           0,
  181.                           0,
  182.                           100,
  183.                           100,
  184.                           NULL,
  185.                           NULL,
  186.                           hExampleInstance,
  187.                           NULL);
  188.   if (hwndTemp) {
  189.     ShowWindow(hwndTemp, nCmdShow);
  190.     UpdateWindow(hwndTemp);
  191.     return (TRUE);
  192.   } else
  193.     return (FALSE);
  194. }
  195.  
  196. /*
  197.  *
  198.  * Re-execute all queries and load all combo boxes
  199.  *
  200.  */
  201.  
  202. static void     near
  203. ExampleRefresh()
  204. {
  205.   if (UserComboBoxRefresh())
  206.     if (TableComboBoxRefresh())
  207.       RecordComboBoxRefresh();
  208. }
  209.  
  210. /*
  211.  *
  212.  * Example Window Procedure:
  213.  *
  214.  */
  215.  
  216. long FAR        PASCAL
  217. ExampleWndProc(HWND hwndTemp, WORD wMessage, WORD wParam, LONG lParam)
  218. {
  219.   HCURSOR         hcursorOld;
  220.   PAINTSTRUCT     psPaintStructure;
  221.   POINT           pointRecordComboBoxLeftTop;
  222.   unsigned        nNotificationCode;
  223.  
  224.   switch (wMessage) {
  225.     case WM_CLOSE:
  226.     case WM_QUERYENDSESSION:
  227.       if (hSqlUser)
  228.         SqlLogout(hSqlUser, &SqlControl);
  229.       if (pstrRecordRecord)
  230.         pstrRecordRecord = (PSTR) LocalFree((HANDLE) pstrRecordRecord);
  231.       if (pstrRecordTable)
  232.         pstrRecordTable = (PSTR) LocalFree((HANDLE) pstrRecordTable);
  233.       if (pstrRecordUser)
  234.         pstrRecordUser = (PSTR) LocalFree((HANDLE) pstrRecordUser);
  235.       break;
  236.     case WM_COMMAND:
  237.       switch (wParam) {
  238.         case IDM_REFRESH:
  239.           hcursorOld = SetCursor(hcursorHourGlass);
  240.           RecordComboBoxRefresh();
  241.           SetCursor(hcursorOld);
  242.           break;
  243.         case IDC_RECORD_BOX:
  244.           break;
  245.         case IDC_TABLE_BOX:
  246.           nNotificationCode = HIWORD(lParam);
  247.           if (nNotificationCode == CBN_SELCHANGE) {
  248.             hcursorOld = SetCursor(hcursorHourGlass);
  249.             RecordComboBoxRefresh();
  250.             SetCursor(hcursorOld);
  251.           }
  252.           break;
  253.         case IDC_USER_BOX:
  254.           nNotificationCode = HIWORD(lParam);
  255.           if (nNotificationCode == CBN_SELCHANGE) {
  256.             hcursorOld = SetCursor(hcursorHourGlass);
  257.             if (TableComboBoxRefresh())
  258.               RecordComboBoxRefresh();
  259.             SetCursor(hcursorOld);
  260.           }
  261.           break;
  262.       }
  263.       break;
  264.     case WM_CREATE:
  265.       hwndExample = hwndTemp;
  266.       hcursorOld = SetCursor(hcursorHourGlass);
  267.       ExampleCreate();
  268.       SetCursor(hcursorOld);
  269.       break;
  270.     case WM_DESTROY:
  271.       PostQuitMessage(0);
  272.       break;
  273.     case WM_PAINT:
  274.       pointRecordComboBoxLeftTop.x = rectRecordComboBox.left + rectExample.left;
  275.       pointRecordComboBoxLeftTop.y = rectRecordComboBox.top + rectExample.top;
  276.       ScreenToClient(hwndExample, &pointRecordComboBoxLeftTop);
  277.       BeginPaint(hwndTemp, &psPaintStructure);
  278.       TextOut(psPaintStructure.hdc, 0, mExampleMargin + 1, szUserTitle, sizeof(szUserTitle) - 1);
  279.       TextOut(psPaintStructure.hdc, (rectExample.right - rectExample.left) / 2, mExampleMargin + 1, szTableTitle, sizeof(szTableTitle) - 1);
  280.       TextOut(psPaintStructure.hdc, 0, pointRecordComboBoxLeftTop.y + 1, szRecordTitle, sizeof(szRecordTitle) - 1);
  281.       EndPaint(hwndTemp, &psPaintStructure);
  282.       break;
  283.     case WM_SETFOCUS:
  284.       SetFocus(hwndUserComboBox);
  285.       break;
  286.   }
  287.   return (DefWindowProc(hwndTemp, wMessage, wParam, lParam));
  288. }
  289.  
  290. /*
  291.  *
  292.  * Create a Record ComboBox:
  293.  *
  294.  */
  295.  
  296. static void     near
  297. RecordComboBoxCreate(HDC hdcDeviceContext)
  298. {
  299.   POINT           pointUserComboBoxLeftBottom;
  300.   unsigned        nWidth;
  301.  
  302.   nWidth = LOWORD(GetTextExtent(hdcDeviceContext, szRecordTitle, sizeof(szRecordTitle) - 1));
  303.   pointUserComboBoxLeftBottom.x = rectUserComboBox.left;
  304.   pointUserComboBoxLeftBottom.y = rectUserComboBox.bottom;
  305.   ScreenToClient(hwndExample, &pointUserComboBoxLeftBottom);
  306.   hwndRecordComboBox = CreateWindow("ComboBox",
  307.                                     NULL,
  308.                                     (WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_VSCROLL),
  309.                                     nWidth,
  310.                                     pointUserComboBoxLeftBottom.y + mExampleMargin,
  311.                                     rectExample.right - rectExample.left - nWidth - mExampleMargin,
  312.                                     nExampleComboBoxHeight,
  313.                                     hwndExample,
  314.                                     IDC_RECORD_BOX,
  315.                                     hExampleInstance,
  316.                                     NULL);
  317.   GetWindowRect(hwndRecordComboBox, &rectRecordComboBox);
  318.   SendMessage(hwndRecordComboBox, WM_SETFONT, GetStockObject(SYSTEM_FIXED_FONT), 0);
  319. }
  320.  
  321. /*
  322.  *
  323.  * Re-execute query for records and load record combo box
  324.  *
  325.  */
  326.  
  327. static BOOL     near
  328. RecordComboBoxRefresh()
  329. {
  330.   char            szQuery[257];
  331.   HANDLE          hSqlCursorRecord;
  332.   SQLTABLE        SqlTable;
  333.   unsigned        nTableIndex;
  334.   unsigned        nUserIndex;
  335.   unsigned long   lRecordPosition;
  336.  
  337.   hSqlCursorRecord = SqlCursorOpen(hSqlUser, &SqlControl);
  338.   nTableIndex = (unsigned) SendMessage(hwndTableComboBox, CB_GETCURSEL, 0, 0);
  339.   nUserIndex = (unsigned) SendMessage(hwndUserComboBox, CB_GETCURSEL, 0, 0);
  340.   SendMessage(hwndTableComboBox, CB_GETLBTEXT, nTableIndex, (LONG) (LPSTR) pstrRecordTable);
  341.   SendMessage(hwndUserComboBox, CB_GETLBTEXT, nTableIndex, (LONG) (LPSTR) pstrRecordUser);
  342.   wsprintf(szQuery, szRecordSelectStatement, (LPSTR) pstrRecordUser, (LPSTR) pstrRecordTable);
  343.   SqlControl.nPadding = 2;
  344.   SqlControl.wFlags = mSqlFlagFormatPadded;
  345.   if (SqlExecute(hSqlUser, hSqlCursorRecord, &SqlControl, szQuery)) {
  346.     SqlDescribeTable(hSqlUser, hSqlCursorRecord, &SqlControl, &SqlTable);
  347.     if (pstrRecordRecord)
  348.       LocalFree((HANDLE) pstrRecordRecord);
  349.     pstrRecordRecord = (PSTR) LocalAlloc(LPTR, SqlTable.nRecordSize);
  350.     SqlControl.nRecordBufferSize = SqlTable.nRecordSize;
  351.     SendMessage(hwndRecordComboBox, CB_RESETCONTENT, 0, 0);
  352.     for (lRecordPosition = 0; lRecordPosition < SqlTable.lNumberOfRecords; lRecordPosition++) {
  353.       if (lRecordPosition)
  354.         SqlFetchNext(hSqlUser, hSqlCursorRecord, &SqlControl, pstrRecordRecord);
  355.       else
  356.         SqlFetchFirst(hSqlUser, hSqlCursorRecord, &SqlControl, pstrRecordRecord);
  357.       if (SqlControl.nResultCode)
  358.         MessageBox(hwndExample, SqlControl.szErrorMessage, szExampleTitle, MB_OK | MB_ICONSTOP);
  359.       SendMessage(hwndRecordComboBox, CB_ADDSTRING, 0, (LONG) (LPSTR) pstrRecordRecord);
  360.     }
  361.     SendMessage(hwndRecordComboBox, CB_SETCURSEL, 0, 0);
  362.   } else
  363.     MessageBox(hwndExample, SqlControl.szErrorMessage, szExampleTitle, MB_OK | MB_ICONSTOP);
  364.   SqlExecute(hSqlUser, hSqlCursorRecord, &SqlControl, szExampleCommit);
  365.   SqlCursorClose(hSqlUser, hSqlCursorRecord, &SqlControl);
  366.   return (!SqlControl.nResultCode);
  367. }
  368.  
  369. /*
  370.  *
  371.  * Create a Table ComboBox:
  372.  *
  373.  */
  374.  
  375. static void     near
  376. TableComboBoxCreate(HDC hdcDeviceContext)
  377. {
  378.   unsigned        nWidth;
  379.  
  380.   nWidth = LOWORD(GetTextExtent(hdcDeviceContext, szTableTitle, sizeof(szTableTitle) - 1));
  381.   hwndTableComboBox = CreateWindow("ComboBox",
  382.                                    NULL,
  383.                                    (WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_VSCROLL),
  384.                                    nWidth + (rectExample.right - rectExample.left) / 2,
  385.                                    mExampleMargin,
  386.                                    (rectExample.right - rectExample.left) / 2 - nWidth - mExampleMargin,
  387.                                    nExampleComboBoxHeight,
  388.                                    hwndExample,
  389.                                    IDC_TABLE_BOX,
  390.                                    hExampleInstance,
  391.                                    NULL);
  392.   GetWindowRect(hwndTableComboBox, &rectTableComboBox);
  393.   SendMessage(hwndTableComboBox, WM_SETFONT, GetStockObject(SYSTEM_FIXED_FONT), 0);
  394. }
  395.  
  396. /*
  397.  *
  398.  * Re-execute query for tables and load table combo box
  399.  *
  400.  */
  401.  
  402. static BOOL     near
  403. TableComboBoxRefresh()
  404. {
  405.   char            szQuery[257];
  406.   HANDLE          hSqlCursorTable;
  407.   SQLTABLE        SqlTable;
  408.   unsigned        nUserIndex;
  409.   unsigned long   lRecordPosition;
  410.  
  411.   hSqlCursorTable = SqlCursorOpen(hSqlUser, &SqlControl);
  412.   nUserIndex = (unsigned) SendMessage(hwndUserComboBox, CB_GETCURSEL, 0, 0);
  413.   SendMessage(hwndUserComboBox, CB_GETLBTEXT, nUserIndex, (LONG) (LPSTR) pstrRecordUser);
  414.   wsprintf(szQuery, szTableSelectStatement, (LPSTR) pstrRecordUser);
  415.   SqlControl.wFlags = mSqlFlagFormatString;
  416.   if (SqlExecute(hSqlUser, hSqlCursorTable, &SqlControl, szQuery)) {
  417.     SqlDescribeTable(hSqlUser, hSqlCursorTable, &SqlControl, &SqlTable);
  418.     if (pstrRecordTable)
  419.       LocalFree((HANDLE) pstrRecordTable);
  420.     pstrRecordTable = (PSTR) LocalAlloc(LPTR, SqlTable.nRecordSize);
  421.     SqlControl.nRecordBufferSize = SqlTable.nRecordSize;
  422.     SendMessage(hwndTableComboBox, CB_RESETCONTENT, 0, 0);
  423.     for (lRecordPosition = 0; lRecordPosition < SqlTable.lNumberOfRecords; lRecordPosition++) {
  424.       if (lRecordPosition)
  425.         SqlFetchNext(hSqlUser, hSqlCursorTable, &SqlControl, pstrRecordTable);
  426.       else
  427.         SqlFetchFirst(hSqlUser, hSqlCursorTable, &SqlControl, pstrRecordTable);
  428.       if (SqlControl.nResultCode)
  429.         MessageBox(hwndExample, SqlControl.szErrorMessage, szExampleTitle, MB_OK | MB_ICONSTOP);
  430.       SendMessage(hwndTableComboBox, CB_ADDSTRING, 0, (LONG) (LPSTR) pstrRecordTable);
  431.     }
  432.     SendMessage(hwndTableComboBox, CB_SETCURSEL, 0, 0);
  433.   } else
  434.     MessageBox(hwndExample, SqlControl.szErrorMessage, szExampleTitle, MB_OK | MB_ICONSTOP);
  435.   SqlCursorClose(hSqlUser, hSqlCursorTable, &SqlControl);
  436.   return (!SqlControl.nResultCode);
  437. }
  438.  
  439. /*
  440.  *
  441.  * Create a User ComboBox:
  442.  *
  443.  */
  444.  
  445. static void     near
  446. UserComboBoxCreate(HDC hdcDeviceContext)
  447. {
  448.   unsigned        nWidth;
  449.  
  450.   nWidth = LOWORD(GetTextExtent(hdcDeviceContext, szUserTitle, sizeof(szUserTitle) - 1));
  451.   hwndUserComboBox = CreateWindow("ComboBox",
  452.                                   NULL,
  453.                                   (WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_VSCROLL),
  454.                                   nWidth,
  455.                                   mExampleMargin,
  456.                                   (rectExample.right - rectExample.left) / 2 - nWidth - mExampleMargin,
  457.                                   nExampleComboBoxHeight,
  458.                                   hwndExample,
  459.                                   IDC_USER_BOX,
  460.                                   hExampleInstance,
  461.                                   NULL);
  462.   GetWindowRect(hwndUserComboBox, &rectUserComboBox);
  463.   SendMessage(hwndUserComboBox, WM_SETFONT, GetStockObject(SYSTEM_FIXED_FONT), 0);
  464. }
  465.  
  466. /*
  467.  *
  468.  * Re-execute query for users and load user combo box
  469.  *
  470.  */
  471.  
  472. static BOOL     near
  473. UserComboBoxRefresh()
  474. {
  475.   HANDLE          hSqlCursorUser;
  476.   SQLTABLE        SqlTable;
  477.   unsigned long   lRecordPosition;
  478.  
  479.   hSqlCursorUser = SqlCursorOpen(hSqlUser, &SqlControl);
  480.   SqlControl.wFlags = mSqlFlagFormatString;
  481.   if (SqlExecute(hSqlUser, hSqlCursorUser, &SqlControl, szUserSelectStatement)) {
  482.     SqlDescribeTable(hSqlUser, hSqlCursorUser, &SqlControl, &SqlTable);
  483.     if (pstrRecordUser)
  484.       LocalFree((HANDLE) pstrRecordUser);
  485.     pstrRecordUser = (PSTR) LocalAlloc(LPTR, SqlTable.nRecordSize);
  486.     SqlControl.nRecordBufferSize = SqlTable.nRecordSize;
  487.     SendMessage(hwndUserComboBox, CB_RESETCONTENT, 0, 0);
  488.     for (lRecordPosition = 0; lRecordPosition < SqlTable.lNumberOfRecords; lRecordPosition++) {
  489.       if (lRecordPosition)
  490.         SqlFetchNext(hSqlUser, hSqlCursorUser, &SqlControl, pstrRecordUser);
  491.       else
  492.         SqlFetchFirst(hSqlUser, hSqlCursorUser, &SqlControl, pstrRecordUser);
  493.       if (SqlControl.nResultCode)
  494.         MessageBox(hwndExample, SqlControl.szErrorMessage, szExampleTitle, MB_OK | MB_ICONSTOP);
  495.       SendMessage(hwndUserComboBox, CB_ADDSTRING, 0, (LONG) (LPSTR) pstrRecordUser);
  496.     }
  497.     SendMessage(hwndUserComboBox, CB_SETCURSEL, 0, 0);
  498.   } else
  499.     MessageBox(hwndExample, SqlControl.szErrorMessage, szExampleTitle, MB_OK | MB_ICONSTOP);
  500.   SqlCursorClose(hSqlUser, hSqlCursorUser, &SqlControl);
  501.   return (!SqlControl.nResultCode);
  502. }
  503.  
  504. /*
  505.  *
  506.  * Example Window Program:
  507.  *
  508.  */
  509.  
  510. int             PASCAL
  511. WinMain(HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpstrCmdLine, int nCmdShow)
  512. {
  513.   MSG             msgMessage;
  514.  
  515.   lpstrCmdLine = lpstrCmdLine;
  516.   hExampleInstance = hInstance;
  517.   if (!SqlGetStatus(0, 0, NULL, NULL)) {
  518.     MessageBox(GetFocus(), "The Dba is not running!", szExampleTitle, MB_OK | MB_ICONSTOP);
  519.     return (0);
  520.   }
  521.   if (!hPrevInstance && !ExampleInitializeApplication())
  522.     return (0);
  523.   if (!ExampleInitializeInstance(nCmdShow))
  524.     return (0);
  525.   while (GetMessage(&msgMessage, NULL, 0, 0)) {
  526.     TranslateMessage(&msgMessage);
  527.     DispatchMessage(&msgMessage);
  528.   }
  529.   return (0);
  530. }
  531.